{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "y4bKPPa7DXNs"
      },
      "outputs": [],
      "source": [
        "%pip install mem0ai multion"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Setup and Configuration\n",
        "\n",
        "First, we'll import the necessary libraries and set up our configurations.\n",
        "\n"
      ],
      "metadata": {
        "id": "pe4htqUmDdmS"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import os\n",
        "from mem0 import Memory\n",
        "from multion.client import MultiOn\n",
        "\n",
        "# Configuration\n",
        "OPENAI_API_KEY = 'sk-xxx'  # Replace with your actual OpenAI API key\n",
        "MULTION_API_KEY = 'your-multion-key'  # Replace with your actual MultiOn API key\n",
        "USER_ID = \"deshraj\"\n",
        "\n",
        "# Set up OpenAI API key\n",
        "os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY\n",
        "\n",
        "# Initialize Mem0 and MultiOn\n",
        "memory = Memory()\n",
        "multion = MultiOn(api_key=MULTION_API_KEY)"
      ],
      "metadata": {
        "id": "fsZwK7eLDh3I"
      },
      "execution_count": 2,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Add memories to Mem0\n",
        "\n",
        "Next, we'll define our user data and add it to Mem0."
      ],
      "metadata": {
        "id": "HTGVhGwaDl-1"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Define user data\n",
        "USER_DATA = \"\"\"\n",
        "About me\n",
        "- I'm Deshraj Yadav, Co-founder and CTO at Mem0 (f.k.a Embedchain). I am broadly interested in the field of Artificial Intelligence and Machine Learning Infrastructure.\n",
        "- Previously, I was Senior Autopilot Engineer at Tesla Autopilot where I led the Autopilot's AI Platform which helped the Tesla Autopilot team to track large scale training and model evaluation experiments, provide monitoring and observability into jobs and training cluster issues.\n",
        "- I had built EvalAI as my masters thesis at Georgia Tech, which is an open-source platform for evaluating and comparing machine learning and artificial intelligence algorithms at scale.\n",
        "- Outside of work, I am very much into cricket and play in two leagues (Cricbay and NACL) in San Francisco Bay Area.\n",
        "\"\"\"\n",
        "\n",
        "# Add user data to memory\n",
        "memory.add(USER_DATA, user_id=USER_ID)\n",
        "print(\"User data added to memory.\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "xB3tm0_pDm6e",
        "outputId": "aeab370c-8679-4d39-faaa-f702146d2fc4"
      },
      "execution_count": 3,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "User data added to memory.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Retrieving Relevant Memories\n",
        "\n",
        "Now, we'll define our search command and retrieve relevant memories from Mem0."
      ],
      "metadata": {
        "id": "ZCPUJf0TDqUK"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Define search command and retrieve relevant memories\n",
        "command = \"Find papers on arxiv that I should read based on my interests.\"\n",
        "\n",
        "relevant_memories = memory.search(command, user_id=USER_ID, limit=3)\n",
        "relevant_memories_text = '\\n'.join(mem['text'] for mem in relevant_memories)\n",
        "print(f\"Relevant memories:\")\n",
        "print(relevant_memories_text)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "s0PwAhNVDrIv",
        "outputId": "59cbb767-b468-4139-8d0c-fa763918dbb0"
      },
      "execution_count": 10,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Relevant memories:\n",
            "Name: Deshraj Yadav - Co-founder and CTO at Mem0 (formerly known as Embedchain) - Interested in Artificial Intelligence and Machine Learning Infrastructure - Previous role: Senior Autopilot Engineer at Tesla Autopilot - Led the Autopilot's AI Platform at Tesla, focusing on large scale training, model evaluation, monitoring, and observability - Built EvalAI as a master's thesis at Georgia Tech, an open-source platform for evaluating and comparing machine learning algorithms - Enjoys cricket - Plays in two cricket leagues: Cricbay and NACL in the San Francisco Bay Area\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Browsing arXiv\n",
        "\n",
        "Finally, we'll use MultiOn to browse arXiv based on our command and relevant memories."
      ],
      "metadata": {
        "id": "jdge78_VDtgv"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Create prompt and browse arXiv\n",
        "prompt = f\"{command}\\n My past memories: {relevant_memories_text}\"\n",
        "browse_result = multion.browse(cmd=prompt, url=\"https://arxiv.org/\")\n",
        "print(browse_result)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "4T_tLURTDvS-",
        "outputId": "259ff32f-5d42-44e6-f2ef-c3557a8e9da6"
      },
      "execution_count": 11,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "message=\"Summarizing the relevant papers found so far that align with Deshraj Yadav's interests in Artificial Intelligence and Machine Learning Infrastructure.\\n\\n1. **Urban Waterlogging Detection: A Challenging Benchmark and Large-Small Model Co-Adapter**\\n   - Authors: Suqi Song, Chenxu Zhang, Peng Zhang, Pengkun Li, Fenglong Song, Lei Zhang\\n   - Abstract: Urban waterlogging poses a major risk to public safety. Conventional methods using water-level sensors need high-maintenance to hardly achieve full coverage. Recent advances employ surveillance camera imagery and deep learning for detection, yet these struggle amidst scarce data and adverse environments.\\n   - Date: 10 July, 2024\\n\\n2. **Intercepting Unauthorized Aerial Robots in Controlled Airspace Using Reinforcement Learning**\\n   - Authors: Francisco Giral, Ignacio Gómez, Soledad Le Clainche\\n   - Abstract: Ensuring the safe and efficient operation of airspace, particularly in urban environments and near critical infrastructure, necessitates effective methods to intercept unauthorized or non-cooperative UAVs. This work addresses the critical need for robust, adaptive systems capable of managing such scenarios.\\n   - Date: 9 July, 2024\\n\\n3. **Efficient Materials Informatics between Rockets and Electrons**\\n   - Authors: Adam M. Krajewski\\n   - Abstract: This paper discusses the distinct efforts existing at three general scales of abstractions of what a material is - atomistic, physical, and design. At each, an efficient materials informatics is being built from the ground up based on the fundamental understanding of the underlying prior knowledge, including the data.\\n   - Date: 5 July, 2024\\n\\n4. **ObfuscaTune: Obfuscated Offsite Fine-tuning and Inference of Proprietary LLMs on Private Datasets**\\n   - Authors: Ahmed Frikha, Nassim Walha, Ricardo Mendes, Krishna Kanth Nakka, Xue Jiang, Xuebing Zhou\\n   - Abstract: This paper proposes ObfuscaTune, a novel, efficient, and fully utility-preserving approach that combines a simple yet effective method to ensure the confidentiality of both the model and the data during offsite fine-tuning on a third-party cloud provider.\\n   - Date: 3 July, 2024\\n\\n5. **MG-Verilog: Multi-grained Dataset Towards Enhanced LLM-assisted Verilog Generation**\\n   - Authors: Yongan Zhang, Zhongzhi Yu, Yonggan Fu, Cheng Wan, Yingyan Celine Lin\\n   - Abstract: This paper discusses the necessity of providing domain-specific data during inference, fine-tuning, or pre-training to effectively leverage LLMs in hardware design. Existing publicly available hardware datasets are often limited in size, complexity, or detail, which hinders the effectiveness of LLMs in this domain.\\n   - Date: 1 July, 2024\\n\\n6. **The Future of Aerial Communications: A Survey of IRS-Enhanced UAV Communication Technologies**\\n   - Authors: Zina Chkirbene, Ala Gouissem, Ridha Hamila, Devrim Unal\\n   - Abstract: The advent of Reflecting Surfaces (IRS) and Unmanned Aerial Vehicles (UAVs) is setting a new benchmark in the field of wireless communications. IRS, with their groundbreaking ability to manipulate electromagnetic waves, have opened avenues for substantial enhancements in signal quality, network efficiency, and spectral usage.\\n   - Date: 2 June, 2024\\n\\n7. **Scalable and RISC-V Programmable Near-Memory Computing Architectures for Edge Nodes**\\n   - Authors: Michele Caon, Clément Choné, Pasquale Davide Schiavone, Alexandre Levisse, Guido Masera, Maurizio Martina, David Atienza\\n   - Abstract: The widespread adoption of data-centric algorithms, particularly AI and ML, has exposed the limitations of centralized processing, driving the need for scalable and programmable near-memory computing architectures for edge nodes.\\n   - Date: 20 June, 2024\\n\\n8. **Enhancing robustness of data-driven SHM models: adversarial training with circle loss**\\n   - Authors: Xiangli Yang, Xijie Deng, Hanwei Zhang, Yang Zou, Jianxi Yang\\n   - Abstract: Structural health monitoring (SHM) is critical to safeguarding the safety and reliability of aerospace, civil, and mechanical infrastructures. This paper discusses the use of adversarial training with circle loss to enhance the robustness of data-driven SHM models.\\n   - Date: 20 June, 2024\\n\\n9. **Understanding Pedestrian Movement Using Urban Sensing Technologies: The Promise of Audio-based Sensors**\\n   - Authors: Chaeyeon Han, Pavan Seshadri, Yiwei Ding, Noah Posner, Bon Woo Koo, Animesh Agrawal, Alexander Lerch, Subhrajit Guhathakurta\\n   - Abstract: Understanding pedestrian volumes and flows is essential for designing safer and more attractive pedestrian infrastructures. This study discusses a new approach to scale up urban sensing of people with the help of novel audio-based technology.\\n   - Date: 14 June, 2024\\n\\nASK_USER_HELP: Deshraj, I have found several papers that might be of interest to you. Would you like to proceed with any specific papers from the list above, or should I refine the search further?\\n\" status='NOT_SURE' url='https://arxiv.org/search/?query=Artificial+Intelligence+Machine+Learning+Infrastructure&searchtype=all&source=header' screenshot='' session_id='ff2ee9ef-60d4-4436-bc36-a81d94e0f410' metadata=Metadata(step_count=9, processing_time=66, temperature=0.2)\n"
          ]
        }
      ]
    }
  ]
}